import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;

public class Anthropometry extends JPanel
{
    public Anthropometry()
    {
        super(new BorderLayout());
        a = new ArrayList<AnthropometryData> (3);
        a.add(AnthropometryData.getAnthropometry());
        initFields();
        setValues();
        JPanel panel_aux = new JPanel();
        panel_aux.add(getAnthropometryPanel());
        add(panel_aux,BorderLayout.NORTH);
        add(getConfirmPanel(),BorderLayout.CENTER);
    }
    public Anthropometry(ArrayList<AnthropometryData> a_)
    {
        super(new BorderLayout());
        a = a_;
        initFields();
        setValues();
        JPanel panel_aux = new JPanel();
        panel_aux.add(getAnthropometryPanel());
        add(panel_aux,BorderLayout.NORTH);
        add(getConfirmPanel(),BorderLayout.CENTER);
    }
    public void update(ArrayList<AnthropometryData> a_)
    {
    	a = a_;
    	dateCombo.removeAllItems();
    	DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, new Locale("es","MX"));
    	//String[] stringDate = new String[a.size()];
        for(int i = 0; i < a.size(); i++)
        	dateCombo.addItem(df.format(a.get(i).getDate()));
        setValues();
    }
    public void update(ArrayList<AnthropometryData> a_,int selectedIndex)
    {
    	a = a_;
    	dateCombo.removeAllItems();
    	DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, new Locale("es","MX"));
    	//String[] stringDate = new String[a.size()];
        for(int i = 0; i < a.size(); i++)
        	dateCombo.addItem(df.format(a.get(i).getDate()));
        dateCombo.setSelectedIndex(selectedIndex);
        setValues();
    }
    public void initFields()
    {
    	isSaved = false;
    	DateFormat df = Resources.getDateFormat();
    	String[] stringDate = new String[a.size()];
        for(int i = 0; i < a.size(); i++)
        	stringDate[i] = df.format(a.get(i).getDate());
        dateCombo = Components.getComboBox(stringDate);
        dateCombo.setSelectedIndex(a.size()-1);
        currentWeightField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        targetWeightField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        sizeField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_subscapularisField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_tricepField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_bicepField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_forearmField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_supraspinalField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_suprailiacField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_abdLeftField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_abdRightField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_thighField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_legField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        c_pectoralField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_relaxedArmField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_contractedArmField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_forearmField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_wristField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_chestField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_abdominalField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_glutealField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_thighField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        g_legField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        d_humeralField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        d_femoralField = Components.getFormattedTextField(NumberFormat.getNumberInstance());
        d_bioestiloideoField = Components.getFormattedTextField(NumberFormat.getNumberInstance());        
    }
    public void setValues()
    {
        //Anthropometry
        currentWeightField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A.CURRRENT_WEIGHT));
        targetWeightField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A.TARGET_WEIGHT));
        sizeField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A.SIZE));
        //Crease
        c_subscapularisField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.SUBSCAPULARIS));
        c_tricepField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.TRICEP));
        c_bicepField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.BICEP));
        c_forearmField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.FOREARM));
        c_supraspinalField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.SUPRASPINAL));
        c_suprailiacField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.SUPRAILIAC));
        c_abdLeftField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.ABD_LEFT));
        c_abdRightField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.ABD_RIGHT));
        c_thighField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.THIGH));
        c_legField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.LEG));
        c_pectoralField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.PECTORAL));
        //Girth
        g_relaxedArmField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.RELAXED_ARM));
        g_contractedArmField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.CONTRACTED_ARM));
        g_forearmField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.FOREARM));
        g_wristField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.WRIST));
        g_chestField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.CHEST));
        g_abdominalField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.ABDOMINAL));
        g_glutealField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.GLUTEAL));
        g_thighField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.THIGH));
        g_legField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.LEG));
        //Diameter
        d_humeralField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_DIAMETER.HUMERAL));
        d_femoralField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_DIAMETER.FEMORAL));
        d_bioestiloideoField.setValue(
            a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_DIAMETER.BIOESTILOIDEO));
    }
    public AnthropometryData getData()
    {
        return a.get(dateCombo.getSelectedIndex());
    }
    public ArrayList<AnthropometryData> getList()
    {
        return a;
    }
    public int getIndexCheckup()
    {
    	return dateCombo.getSelectedIndex();
    }
    private JPanel getAnthropometryPanel()
    {
        JPanel panelA = new JPanel(new BorderLayout());
        Border etched = BorderFactory.createEmptyBorder();
        Border titled = BorderFactory.createTitledBorder(
            etched, 
            Resources.getString("anthropometry"),
            TitledBorder.LEFT, 
            TitledBorder.TOP, 
            Resources.getFont(Resources.FONT_TYPE.BORDER)
        );
        dateCombo.addItemListener(new 
    		ItemListener()
    		{
        		public void itemStateChanged(ItemEvent e)
        		{
        			int state = e.getStateChange();
        			if(state == ItemEvent.SELECTED)
        				setValues();
        		}
    		}
        );
        /*JButton addDateButton = new JButton(Resources.getString("add"));
        addDateButton.addActionListener(new 
        		ActionListener()
        		{
					public void actionPerformed(ActionEvent e) 
					{
						DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, new Locale("es","MX"));
						if(!df.format(a.get(a.size()-1).getDate()).equals(df.format(new Date())))
				        {
				        	a.add(AnthropometryData.getAnthropometry());
				        	dateCombo.addItem(df.format(new Date()));
				        }
					}
        		}
        );
        JButton deleteDateButton = new JButton(Resources.getString("delete"));*/
        panelA.setBorder(titled);
        JLabel dateLabel = Components.getLabel(Resources.getString("date"));
        JLabel dateUnitsLabel = Components.getLabel(Resources.getString("dateUnits"),Resources.FONT_TYPE.LABELS);
        JLabel currentWeightLabel = Components.getLabel(Resources.getString("currentWeight"));
        JLabel currentWeightUnitsLabel = Components.getLabel(Resources.getString("weightUnits"),Resources.FONT_TYPE.LABELS);
        JLabel targetWeightLabel = Components.getLabel(Resources.getString("targetWeight"));
        JLabel targetWeightUnitsLabel = Components.getLabel(Resources.getString("weightUnits"),Resources.FONT_TYPE.LABELS);
        JLabel sizeLabel = Components.getLabel(Resources.getString("size"));
        JLabel sizeUnitsLabel = Components.getLabel(Resources.getString("sizeUnits"),Resources.FONT_TYPE.LABELS);
        JLabel c_subscapularisLabel = Components.getLabel(Resources.getString("subscapularis"));
        JLabel c_tricepLabel = Components.getLabel(Resources.getString("tricep"));
        JLabel c_bicepLabel = Components.getLabel(Resources.getString("bicep"));
        JLabel c_forearmLabel = Components.getLabel(Resources.getString("forearm"));
        JLabel c_supraspinalLabel = Components.getLabel(Resources.getString("supraspinal"));
        JLabel c_suprailiacLabel = Components.getLabel(Resources.getString("suprailiac"));
        JLabel c_abdLeftLabel = Components.getLabel(Resources.getString("abdLeft"));
        JLabel c_abdRightLabel = Components.getLabel(Resources.getString("abdRight"));
        JLabel c_thighLabel = Components.getLabel(Resources.getString("thigh"));
        JLabel c_legLabel = Components.getLabel(Resources.getString("leg"));
        JLabel c_pectoralLabel = Components.getLabel(Resources.getString("pectoral"));
        JLabel g_relaxedArmLabel = Components.getLabel(Resources.getString("relaxedArm"));
        JLabel g_contractedArmLabel = Components.getLabel(Resources.getString("contractedArm"));
        JLabel g_forearmLabel = Components.getLabel(Resources.getString("forearm"));
        JLabel g_wristLabel = Components.getLabel(Resources.getString("wrist"));
        JLabel g_chestLabel = Components.getLabel(Resources.getString("chest"));
        JLabel g_abdominalLabel = Components.getLabel(Resources.getString("abdominal"));
        JLabel g_glutealLabel = Components.getLabel(Resources.getString("gluteal"));
        JLabel g_thighLabel = Components.getLabel(Resources.getString("thigh"));
        JLabel g_legLabel = Components.getLabel(Resources.getString("leg"));
        JLabel d_humeralLabel = Components.getLabel(Resources.getString("humeral"));
        JLabel d_femoralLabel = Components.getLabel(Resources.getString("femoral"));
        JLabel d_bioestiloideoLabel = Components.getLabel(Resources.getString("bioestiloideo"));
        JPanel panel_aux1 = new JPanel(new GridLayout(4,3,15,0));
        JPanel panel_aux2 = new JPanel(new GridLayout(11,2,15,0));
        Border etched_aux2 = BorderFactory.createEtchedBorder();
        Border titled_aux2 = BorderFactory.createTitledBorder(
            etched_aux2, 
            Resources.getString("crease")+" ("+Resources.getString("creaseUnits")+")",
            TitledBorder.LEFT, 
            TitledBorder.TOP, 
            Resources.getFont(Resources.FONT_TYPE.BORDER)
        );
        panel_aux2.setBorder(titled_aux2);
        JPanel panel_aux3 = new JPanel(new GridLayout(9,2,15,0));
        Border etched_aux3 = BorderFactory.createEtchedBorder();
        Border titled_aux3 = BorderFactory.createTitledBorder(
            etched_aux3, 
            Resources.getString("girth")+" ("+Resources.getString("girthUnits")+")",
            TitledBorder.LEFT, 
            TitledBorder.TOP, 
            Resources.getFont(Resources.FONT_TYPE.BORDER)
        );
        panel_aux3.setBorder(titled_aux3);
        JPanel panel_aux4 = new JPanel(new GridLayout(3,2,15,0));
        Border etched_aux4 = BorderFactory.createEtchedBorder();
        Border titled_aux4 = BorderFactory.createTitledBorder(
            etched_aux4, 
            Resources.getString("diameter")+" ("+Resources.getString("diameterUnits")+")",
            TitledBorder.LEFT, 
            TitledBorder.TOP, 
            Resources.getFont(Resources.FONT_TYPE.BORDER)
        );
        panel_aux4.setBorder(titled_aux4);
        JPanel panel_aux5 = new JPanel(new GridLayout(1,3,15,0));
        JPanel panel_aux6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        JPanel panel_aux7 = new JPanel(new BorderLayout());
        JPanel panel_aux8 = new JPanel(new BorderLayout());
        
        panel_aux1.add(dateLabel);
        panel_aux1.add(dateCombo);
        panel_aux1.add(dateUnitsLabel);
        panel_aux1.add(currentWeightLabel); 
        panel_aux1.add(currentWeightField); 
        panel_aux1.add(currentWeightUnitsLabel);
        panel_aux1.add(targetWeightLabel); 
        panel_aux1.add(targetWeightField);
        panel_aux1.add(targetWeightUnitsLabel);
        panel_aux1.add(sizeLabel); 
        panel_aux1.add(sizeField);
        panel_aux1.add(sizeUnitsLabel);
        panel_aux6.add(panel_aux1);
        
        panel_aux2.add(c_subscapularisLabel); panel_aux2.add(c_subscapularisField);
        panel_aux2.add(c_tricepLabel); panel_aux2.add(c_tricepField);
        panel_aux2.add(c_bicepLabel); panel_aux2.add(c_bicepField);
        panel_aux2.add(c_forearmLabel); panel_aux2.add(c_forearmField);
        panel_aux2.add(c_supraspinalLabel); panel_aux2.add(c_supraspinalField);
        panel_aux2.add(c_suprailiacLabel); panel_aux2.add(c_suprailiacField);
        panel_aux2.add(c_abdLeftLabel); panel_aux2.add(c_abdLeftField);
        panel_aux2.add(c_abdRightLabel); panel_aux2.add(c_abdRightField);
        panel_aux2.add(c_thighLabel); panel_aux2.add(c_thighField);
        panel_aux2.add(c_legLabel); panel_aux2.add(c_legField);
        panel_aux2.add(c_pectoralLabel); panel_aux2.add(c_pectoralField);
        
        panel_aux3.add(g_relaxedArmLabel); panel_aux3.add(g_relaxedArmField);
        panel_aux3.add(g_contractedArmLabel); panel_aux3.add(g_contractedArmField);
        panel_aux3.add(g_forearmLabel); panel_aux3.add(g_forearmField);
        panel_aux3.add(g_wristLabel); panel_aux3.add(g_wristField);
        panel_aux3.add(g_chestLabel); panel_aux3.add(g_chestField);
        panel_aux3.add(g_abdominalLabel); panel_aux3.add(g_abdominalField);
        panel_aux3.add(g_glutealLabel); panel_aux3.add(g_glutealField);
        panel_aux3.add(g_thighLabel); panel_aux3.add(g_thighField);
        panel_aux3.add(g_legLabel); panel_aux3.add(g_legField);
        panel_aux7.add(panel_aux3, BorderLayout.NORTH);
        
        panel_aux4.add(d_humeralLabel); panel_aux4.add(d_humeralField);
        panel_aux4.add(d_femoralLabel); panel_aux4.add(d_femoralField);
        panel_aux4.add(d_bioestiloideoLabel); panel_aux4.add(d_bioestiloideoField);
        panel_aux8.add(panel_aux4, BorderLayout.NORTH);
        
        panelA.add(panel_aux6,BorderLayout.NORTH);
        panel_aux5.add(panel_aux2);
        panel_aux5.add(panel_aux7);
        panel_aux5.add(panel_aux8);
        panelA.add(panel_aux5,BorderLayout.WEST);
        return panelA;
    }
    private JPanel getConfirmPanel()
    {
        JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER,30,15));
        JButton okButton = new JButton(Resources.getString("ok"));
        okButton.setFont(Resources.getFont(Resources.FONT_TYPE.LABELS));
        okButton.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                	confirmNewValues();
                    isSaved = false;
                }
            }
        );
        JButton cancelButton = new JButton(Resources.getString("cancel"));
        cancelButton.setFont(Resources.getFont(Resources.FONT_TYPE.LABELS));
        cancelButton.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                	setValues();
                }
            }
        );
        JPanel panel_aux1 = new JPanel(new GridLayout(1,2,30,0));
        panel_aux1.add(okButton);
        panel_aux1.add(cancelButton);
        panel.add(panel_aux1);
        return panel;
    }
    public void confirmNewValues()
    {
        //Anthropometry
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A.CURRRENT_WEIGHT,
            ((Number)currentWeightField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A.TARGET_WEIGHT,
            ((Number)targetWeightField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A.SIZE,
            ((Number)sizeField.getValue()).floatValue());
        //Crease
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.SUBSCAPULARIS,
            ((Number)c_subscapularisField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.TRICEP,
            ((Number)c_tricepField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.BICEP,
            ((Number)c_bicepField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.FOREARM,
            ((Number)c_forearmField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.SUPRASPINAL,
            ((Number)c_supraspinalField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.SUPRAILIAC,
            ((Number)c_suprailiacField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.ABD_LEFT,
            ((Number)c_abdLeftField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.ABD_RIGHT,
            ((Number)c_abdRightField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.THIGH,
            ((Number)c_thighField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.LEG,
            ((Number)c_legField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_CREASE.PECTORAL,
            ((Number)c_pectoralField.getValue()).floatValue());
        //Girth
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.RELAXED_ARM,
            ((Number)g_relaxedArmField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.CONTRACTED_ARM,
            ((Number)g_contractedArmField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.FOREARM,
            ((Number)g_forearmField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.WRIST,
            ((Number)g_wristField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.CHEST,
            ((Number)g_chestField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.ABDOMINAL,
            ((Number)g_abdominalField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.GLUTEAL,
            ((Number)g_glutealField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.THIGH,
            ((Number)g_thighField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_GIRTH.LEG,
            ((Number)g_legField.getValue()).floatValue());
        //Diameter
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_DIAMETER.HUMERAL,
            ((Number)d_humeralField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_DIAMETER.FEMORAL,
            ((Number)d_femoralField.getValue()).floatValue());
        a.get(dateCombo.getSelectedIndex()).setAnthropometryValue(
            ID.A_DIAMETER.BIOESTILOIDEO,
            ((Number)d_bioestiloideoField.getValue()).floatValue());
    }
    public boolean existNewInfo()
    {
    	//Anthropometry
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A.CURRRENT_WEIGHT) != ((Number)currentWeightField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A.TARGET_WEIGHT) != ((Number)targetWeightField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A.SIZE) != ((Number)sizeField.getValue()).floatValue())
        	return true;
        //Crease
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.SUBSCAPULARIS) != ((Number)c_subscapularisField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.TRICEP) != ((Number)c_tricepField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.BICEP) != ((Number)c_bicepField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.FOREARM) != ((Number)c_forearmField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.SUPRASPINAL) != ((Number)c_supraspinalField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.SUPRAILIAC) != ((Number)c_suprailiacField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.ABD_LEFT) != ((Number)c_abdLeftField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.ABD_RIGHT) != ((Number)c_abdRightField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.THIGH) != ((Number)c_thighField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.LEG) != ((Number)c_legField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_CREASE.PECTORAL) != ((Number)c_pectoralField.getValue()).floatValue())
        	return true;
        //Girth
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.RELAXED_ARM) != ((Number)g_relaxedArmField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.CONTRACTED_ARM) != ((Number)g_contractedArmField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.FOREARM) != ((Number)g_forearmField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.WRIST) != ((Number)g_wristField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.CHEST) != ((Number)g_chestField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.ABDOMINAL) != ((Number)g_abdominalField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.GLUTEAL) != ((Number)g_glutealField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.THIGH) != ((Number)g_thighField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_GIRTH.LEG) != ((Number)g_legField.getValue()).floatValue())
        	return true;
        //Diameter
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_DIAMETER.HUMERAL) != ((Number)d_humeralField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_DIAMETER.FEMORAL) != ((Number)d_femoralField.getValue()).floatValue())
        	return true;
        if(a.get(dateCombo.getSelectedIndex()).getAnthropometryValue(ID.A_DIAMETER.BIOESTILOIDEO) != ((Number)d_bioestiloideoField.getValue()).floatValue())
        	return true;
        return false;
    }
    public void setSavedState(boolean isSaved_)
    {
    	isSaved = isSaved_;
    }
    public boolean getSavedState()
    {
    	return isSaved;
    }
    private boolean isSaved;
    private ArrayList<AnthropometryData> a;
    //Date
    private JComboBox dateCombo;
    //Anthropometry
    private JFormattedTextField currentWeightField;
    private JFormattedTextField targetWeightField;
    private JFormattedTextField sizeField;
    //Crease
    private JFormattedTextField c_subscapularisField;
    private JFormattedTextField c_tricepField;
    private JFormattedTextField c_bicepField;
    private JFormattedTextField c_forearmField;
    private JFormattedTextField c_supraspinalField;
    private JFormattedTextField c_suprailiacField;
    private JFormattedTextField c_abdLeftField;
    private JFormattedTextField c_abdRightField;
    private JFormattedTextField c_thighField;
    private JFormattedTextField c_legField;
    private JFormattedTextField c_pectoralField;
    //Girth
    private JFormattedTextField g_relaxedArmField;
    private JFormattedTextField g_contractedArmField;
    private JFormattedTextField g_forearmField;
    private JFormattedTextField g_wristField;
    private JFormattedTextField g_chestField;
    private JFormattedTextField g_abdominalField;
    private JFormattedTextField g_glutealField;
    private JFormattedTextField g_thighField;
    private JFormattedTextField g_legField;
    //Diameter
    private JFormattedTextField d_humeralField;
    private JFormattedTextField d_femoralField;
    private JFormattedTextField d_bioestiloideoField;
}
